package com.zhangxi.line.service.impl;

import com.zhangxi.line.dao.NewsUserDao;
import com.zhangxi.line.dao.impl.NewsUserDaoImpl;
import com.zhangxi.line.pojo.NewsUser;
import com.zhangxi.line.service.NewsUserService;
import com.zhangxi.line.util.MD5Util;

/**
 * ClassName: NewsUserServiceImpl
 * Package: com.zhangxi.line.service.impl
 */
public class NewsUserServiceImpl implements NewsUserService {

    private NewsUserDao newsUserDao =new NewsUserDaoImpl();
    @Override
    public NewsUser findByUserName(String username) {
        return newsUserDao.findByUserName(username);
    }

    @Override
    public NewsUser findByUid(Integer uid) {
        return newsUserDao.findByUid(uid);
    }

    @Override
    public int registUser(NewsUser newsUser) {
        // 密码明文转密文
        newsUser.setUserPwd(MD5Util.encrypt(newsUser.getUserPwd()));
        // 存入数据库
        return newsUserDao.insertNewsUser(newsUser);
    }
}